package ntd.util.config.common.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Data
public class BaseEntityMybatis<T extends Model<?>> extends Model<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_UUID)
    public String id;

    @Schema(hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
//    @JsonFormat(pattern = Constant.DATE_FORMAT_STAND)
    private Date createdDate;

    @Schema(hidden = true)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    public String createdBy;

    @Schema(hidden = true)
//    @JsonFormat(pattern = Constant.DATE_FORMAT_STAND)
    @TableField(fill = FieldFill.UPDATE)
    private Date updatedDate;

    @Schema(hidden = true)
    @TableField(fill = FieldFill.UPDATE)
    private String updatedBy;

    @TableLogic(value="0",delval="1")
    private Boolean flag;

    @Version
    private Integer version;

    @TableField(exist = false)
    @ApiModelProperty(value = "子节点列表")
    private List<T> children;

    @Override
    public Serializable pkVal() {
        return this.id;
    }
}
